﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using VideoServer.Helpers;
using VideoServer.ViewModel.Helpers;

namespace VideoServer.ViewModel
{
    public class SystemSettingViewModel:ViewModelBase
    {
        private RelayCommand _changeVidPathCommand = null;
        private RelayCommand _changedFlyPathCommand = null;

        public string VideoSavePath
        {
            get
            {
                return SystemSettingHelper.GetFileSaveSettingValue("VideoSavePath");
            }
        }

        public string FlyInfoSavePath
        {
            get
            {
                 return SystemSettingHelper.GetFileSaveSettingValue("FlyInfoSavePath");
            }
        }

        public RelayCommand ChangeVidPathCommand
        {
            get
            {
                if (_changeVidPathCommand == null)
                    _changeVidPathCommand = new RelayCommand(param=>ChangeVidPath());
                return _changeVidPathCommand;
            }
        }

        
        public RelayCommand ChangedFlyPathCommand
        {
            get
            {
                if (_changedFlyPathCommand == null)
                    _changedFlyPathCommand = new RelayCommand(param=>ChangedFlyPath());
                return _changedFlyPathCommand;
            }
        }
        private void ChangeVidPath()
        {
            FolderBrowserDialog folderDialog = new FolderBrowserDialog();
            folderDialog.ShowDialog();
            if (folderDialog.SelectedPath != string.Empty)
            {
                SystemSettingHelper.SetFileSaveSettingValue("VideoSavePath", folderDialog.SelectedPath);
                OnPropertyChanged("VideoSavePath");
            }

        }

        private void ChangedFlyPath()
        {
            FolderBrowserDialog folderDialog = new FolderBrowserDialog();
            folderDialog.ShowDialog();
            if (folderDialog.SelectedPath != string.Empty)
            {
                SystemSettingHelper.SetFileSaveSettingValue("FlyInfoSavePath", folderDialog.SelectedPath);
                OnPropertyChanged("FlyInfoSavePath");
            }
        }


    }
}
